//本身就是一个时间表
import { urlPrefix as pointSortUrlPrefixs } from '@/views/system/dept/api'
export const crudOptions = (vm) => {
  return {
    pagination: false,
    options: {
      tableType: 'vxe-table',
      stripe: false,
      rowKey: true, // 必须设置，true or false
      rowId: 'id',
      height: '100%', // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false,
      defaultExpandAll: true,
      treeConfig: {
        transform: true,
        rowField: 'id',
        parentField: 'parent',
        expandAll: true,
        accordion: true
      }
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Retrieve')
        }
      },
      edit: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Update')
        }
      },
      remove: {
        thin: true,
        text: '',
        disabled () {
          return !vm.hasPermissions('Delete')
        }
      }
    },
    selectionRow: { // 多选列
      align: 'center',
      width: 55
    },
    indexRow: false,

    viewOptions: {
      componentType: 'form'
    },
    formOptions: {
      defaultSpan: 12, // 默认的表单 span,
      fullscreen: null
    },
    columns: [
      {
        title: 'ID',
        key: 'id',
        show: false,
        disabled: true,
        width: 90,
        form: {
          disabled: true
        }
      },


     {
        title: '页头名称',
        key: 'name',
        search: {
          disabled: false
        },
        form: {
          rules: [
            { required: true, message: '页头名称必填' }
          ],
          component: {
            placeholder: '请输入页面名称'
          }
        }
      },
      {
        title: '页头编码',
        key: 'code',
        search: {
          disabled: false
        },
        form: {
          rules: [
            { required: true, message: '页头编码必填' }
          ],
          component: {
            placeholder: '请输入页头编码'
          }
        }
      },
            {
        title: '部门名称',
          search: {
          disabled: false
        },
        key: 'dept',
        type: 'select',
        dict: {
            //users表
            url: pointSortUrlPrefixs + '?limit=999',
//            用户界面展示的是name，divider表dept外键字段存入的是dept表中的id
            label:'name',
            value:'id'
        },
        form: {
          rules: [
            { required: true, message: '该字段是必填的' },
          ],
          component: {
            placeholder: '请选择部门',
            props: { filterable: true, multiple: false, clearable: true }
          }
        }
      },
      {
        title: '创建时间',
        key: 'create_datetime',
        form: {
          disabled: true
        }
      }
    ]
  }
}
